<template>
	<view class="theme-item">
		<navigator v-if="!isMore" :url="`/pages/detail/detail?name=${item.name}&id=${item._id}`" class="box">
			<image :src="item.picurl" class="picture" mode="aspectFill"></image>
			<view class="tab">
				<view class="point"></view>
				<text class="text">{{ timestampToRelativeTime(item.updateTime) }}更新</text>
			</view>
			<view class="mask">
				{{ item.name }}
			</view>
		</navigator>
		<navigator v-else url="/pages/classify/classify" open-type="reLaunch" class="box more">
			<image src="/static/more.jpg" class="picture" mode="aspectFill"></image>
			<div class="mask">
				<uni-icons type="more-filled" color="#fff"></uni-icons>
				<text class="text">更多</text>
			</div>
		</navigator>
	</view>
</template>

<script setup>
	import {
		timestampToRelativeTime
	} from '@/utils/common.js'

	defineProps({
		isMore: {
			type: Boolean,
			default: () => {
				return false
			}
		},
		item: {
			type: Object,
			default: () => {
				return {}
			}
		}
	})
</script>

<style lang="scss" scoped>
	.theme-item {
		.box {
			height: 340rpx;
			border-radius: 8rpx;
			contain: paint;
			position: relative;

			.tab {
				position: absolute;
				top: 0;
				left: 0;
				backdrop-filter: blur(20rpx);
				background: rgba(250, 129, 90, .7);
				padding: 6rpx 15rpx;
				border-radius: 0 0 20rpx 0;
				transform: scale(.9);
				transform-origin: left top;

				.text {
					font-size: 22rpx;
					color: #fff;
					font-weight: 600;
					word-spacing: 2rpx;
				}
			}

			.picture {
				width: 100%;
			}

			.mask {
				width: 100%;
				height: 70rpx;
				position: absolute;
				color: #fff;
				bottom: 0;
				left: 0;
				backdrop-filter: blur(20rpx);
				display: flex;
				justify-content: center;
				align-items: center;
				font-weight: 600;
			}
		}

		.box.more {
			.mask {
				width: 100%;
				height: 100%;
				display: flex;
				justify-content: center;
				align-items: center;
				flex-direction: column;

				.text {
					font-size: 22rpx;
				}
			}
		}
	}
</style>